const mongoose = require('../../../dao/mongo/mongo');
const Schema = mongoose.Schema;

//宝箱打开记录
const openLogSchema = new Schema({
  box_id: {   //宝箱ID
    type:String 
  },
  grade: {    //量级，少量，大量，巨量
    type: String,
    enum: ["few", "large", "huge"],
  },
  type: {    //奖品类型，金币或石油
    type: String,
    enum: ["coins", "oil"],
  },
  num: {    //奖品数量
    type: String,
  },
  open_at:{    //打开时间
    type:Date,
    default:(new Date()).valueOf()
  }
});

//宝箱获取记录
const giveLogSchema = new Schema({
  boxId: {   //宝箱ID
    type:String 
  },
  give_at:{    //获取时间
    type:Date,
    default:(new Date()).valueOf()
  },
});

//宝箱记录
const boxSchema = new Schema({
  uid: {    //用户ID
    type: String,
    required: true
  },
  give_log: [   //宝箱获取记录
    giveLogSchema
  ],
  open_log: [    //宝箱打开记录
    openLogSchema
  ],
});

module.exports = mongoose.model('treasureBox', boxSchema);
